package com.coldworks.coldjoke.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegularUtil {

	public RegularUtil() {

	}

	public static boolean checkReply(String reply) {
		Pattern IMG_PATTERN = Pattern.compile("\\S{2,}");
		Matcher matcher = IMG_PATTERN.matcher(reply);
		boolean isMatched = matcher.matches();
		return isMatched;
	}

	public static boolean checkContent(String content) {
		Pattern IMG_PATTERN = Pattern.compile("\\S{10,}");
		Matcher matcher = IMG_PATTERN.matcher(content);
		boolean isMatched = matcher.matches();
		return isMatched;
	}

	public static boolean checkEmailAdress(String email) {
		Pattern IMG_PATTERN = Pattern
				.compile("^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$");
		Matcher matcher = IMG_PATTERN.matcher(email);
		boolean isMatched = matcher.matches();
		return isMatched;
	}

	public static boolean checkUserName(String name) {
		Pattern IMG_PATTERN = Pattern.compile("(?=.*[a-zA-Z0-9]).{2,12}$");
		Matcher matcher = IMG_PATTERN.matcher(name);
		boolean isMatched = matcher.matches();
		return isMatched;
	}

	public static boolean checkPwd(String pwd) {
		Pattern IMG_PATTERN = Pattern.compile("^(?=.*[a-zA-Z0-9]).{6,20}$");
		Matcher matcher = IMG_PATTERN.matcher(pwd);
		boolean isMatched = matcher.matches();
		return isMatched;
	}
}
